/*
ID: icerupt1
PROG: castle
LANG: C++11
*/
#include <fstream>
#include <iostream>
#include <algorithm>
#include <queue>
#include <queue>
#include <utility>

int const opt[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
int const maxn = 51;
int const maxs = maxn * maxn;
int da[maxn][maxn];
int map[maxs][5];
int color[maxs];
int count_color[maxs];
int n, m, num_room;

int bfs()
{
	bool vis[n*m];
	//std::fill(std::begin(vis), std::end(vis), false); FIXME
	for (int i = 0; i < n*m; i++) vis[i] = false;
	int max_area = 1, co = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			int tmp = i * m + j;
			if (vis[tmp]) continue;
			vis[tmp] = true;
			std::queue<int> q{{tmp}}; //position area
			count_color[++co]++;  color[tmp] = co;
			while (!q.empty()) {
				int npos = q.front();
				q.pop();
				for (int i = 1; i <= map[npos][0]; i++) {
					int ppos = map[npos][i];
					if (vis[ppos]) continue;
					vis[ppos] = true;
					q.push(ppos);
					color[ppos] = co;
					max_area = std::max(max_area, ++count_color[co]);
				}
			}
		}
	num_room = co;
	return max_area;
}

bool inrange(int x, int y)
{
	return ((0 <= x && x < n) && (0 <= y && y < m));
}

int main()
{
	std::ifstream fin {"castle.in" };
	std::ofstream fout{"castle.out"};

	fin >> m >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			fin >> da[i][j];
			int num = i * m + j;
			for (int k = 0; k < 4; k++) {
				int px = opt[k][0] + i, py = opt[k][1] + j;
				if (!(da[i][j]&(1<<k)) && inrange(px, py)) {
					map[num][++map[num][0]] = px * m + py;
				}
			}
		}

	int large_room = bfs();
	fout << num_room << "\n";
	fout << large_room << "\n";

	int max_merge = 0, ansx, ansy, answ;
	for (int j = 0; j < m; j++)
		for (int i = n-1; i >= 0; i--) {
			int now = i * m + j;
			for (int k = 1; k <= 2; k++) {
				int px = opt[k][0] + i, py = opt[k][1] + j;
				int adj = px * m + py;
				if ((da[i][j]&(1<<k)) && inrange(px, py) && color[now] != color[adj]
						&& count_color[color[now]] + count_color[color[adj]] > max_merge) {
					max_merge = count_color[color[now]] + count_color[color[adj]];
					ansx = i + 1; ansy = j + 1; answ = k;
				}
			}
		}
	fout << max_merge << "\n";
	fout << ansx << ' ' << ansy << ' ' << ((answ == 1) ? 'N' : 'E') << "\n";
}
